{include file="public/toper" /}
<script type="text/javascript" src="/static/js/kalendae.standalone.js"></script>
<link rel="stylesheet" href="/static/css/kalendae.css">
<div class="x-nav">
  <span class="layui-breadcrumb">
    <a href="">商品管理</a>
    <a href="">商品信息</a>
    <a>
      <cite>库存管理</cite></a>
  </span>
  <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
    <i class="layui-icon" style="line-height:30px">ဂ</i></a>
</div>
<div class="x-body">
    <div class="layui-form" id="admin">
        <input type="hidden" name="goods_id" value="{$_GET['id']}">
        {volist name="spec_info" id="vo"}
           <div class="layui-form-item" id="goodsSpec" style="margin-bottom:10px;">
                <label for="order_sn" class="layui-form-label">
                    <span class="x-red">*</span>商品规格
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="spec" name="barcodes" required="" value="{$vo['price_key_name']}" class="layui-input">
                </div>
                <span style="line-height:38px;color:green;">库存:{$vo.store}</span>
            </div>

            {volist name="vo.code_info" id="v"}
                <div class="layui-form-item" id="selectCode">
                      <label for="spec" class="layui-form-label" style="margin-left:5%;">
                          <span class="x-red">*</span>编码
                      </label>
                      <div class="layui-input-inline">
                          <input type="text" id="spec" name="barcodes" required="" value="{$v['barcodes']}" class="layui-input">
                      </div>
                      <button class="layui-btn sail-code" data-id="{$v['code_id']}" data-priceId="{$v['price_id']}" {$v['state']== 1?'disabled style="background-color:#ccc;"':''} lay-submit="" lay-filter="sreach">{$v['state'] == 1?'已出售':'出售'}</button>
                      <?php if($v['state'] == 1 && $v['sale_type'] != 0){ ?><button class="layui-btn" disabled style="background-color:#ccc;" lay-filter="sreach">{if condition="$v['sale_type'] eq 1"}在线销售{elseif condition="$v['sale_type'] eq 2"}店面销售{/if}</button><?php } ?>
                      {if condition = "$v['state'] eq 1"}<button class="layui-btn" disabled style="background-color:#ccc;" lay-filter="sreach">{$v['update_time']|date="Y-m-d H:i:s",###}</button>{/if}
                </div>
            {/volist}
        {/volist}
        
    </div>
</div>
<script>
    layui.use(['upload','laydate'], function(){
        var $ = layui.jquery,
            upload = layui.upload;
        var laydate = layui.laydate;
    });




    layui.use(['form','element','layer','jquery'], function(){
        $ = layui.jquery;
        var form = layui.form
            ,element=layui.element
            ,layer = layui.layer
            ,$=layui.jquery;

        //自定义验证规则
        form.verify({
        });
    });
    
    $(document).on('click','.sail-code',function(){
        var code_id = $(this).attr('data-id');
        var price_id = $(this).attr('data-priceId');
        console.log(code_id);
        console.log(price_id);
        $.ajax({
           type:'POST',
           url:"{:url('Goods/changeCodeState')}",
           data:{code_id:code_id,price_id:price_id},
           success:function(res){
             console.log(res);
             if(res.code == 200){
                 layer.msg(res.msg,{icon: 6});
                 setInterval("location.reload()",2000);
             }else{
                 layer.msg(res.msg,{icon: 2});
             }
           }
        });
    });
</script>
{include file="public/footer" /}